public class Test {
    public static void main(String[] args) throws InterruptedException {
        Object o1 = new Object();
        Object o2 = new Object();
        Object o3 = new Object();
        for (int i = 0; i < 10 ; i++) {
            Thread t1 = new Thread(()->{
                synchronized (o1) {
                    System.out.print("A");
                }
            });
            Thread t2 = new Thread(()->{
                synchronized (o2) {
                    System.out.print("B");
                }
            });
            Thread t3 = new Thread(()->{
                synchronized (o3) {
                    System.out.print("C");
                }
            });
            t1.start();
            t1.join();
            t2.start();
            t2.join();
            t3.start();
            t3.join();


            System.out.println();
        }
    }
}
